﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__PUBLIC__/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__PUBLIC__/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="__PUBLIC__/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>工务段管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 工务段管理 <span
        class="c-gray en">&gt;</span> 工务段管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                               href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray"><span class="l"> <a href="javascript:;" onclick="deleteBatch();"
                                                          class="btn btn-danger radius"><i class="Hui-iconfont">
        &#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" href="javascript:;"
                                 onclick="admin_role_add('添加班组','work-section-add.html','600','300')"><i
            class="Hui-iconfont">&#xe600;</i> 添加工务段</a> </span> <span class="r">共有数据：<strong>54</strong> 条</span></div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="6">工务段管理</th>
        </tr>
        <tr class="text-c">
            <th width="10%"><input type="checkbox" value="" name="" id="checkMg"></th>
            <th width="10%">ID</th>
            <th width="30%">工务段名称</th>
            <th width="30%">工务段描述</th>
            <th width="">操作</th>
        </tr>
        </thead>
        <tbody>

        <foreach name="sections" item="vo">
            <tr class="text-c" id="{$vo.sec_id}">
                <td><input type="checkbox" value="{$vo.sec_id}" name="sec_id_check"></td>
                <td>{$vo.sec_id}</td>
                <td>{$vo.sec_name}</td>
                <td>{$vo.sec_note}</td>
                <td class="f-14"><a title="编辑" href="javascript:;"
                                    onclick="admin_role_edit('工务段编辑','work_seciton_edit.html?id={$vo.sec_id}','{$vo.sec_id}',600,300)"
                                    style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除"
                                                                                                             href="javascript:;"
                                                                                                             onclick='admin_role_del(this,"{:U('Index/Duty/work_section_del',array('id'=>$vo['sec_id']))}")'
                    class="ml-5"
                    style="text-decoration:none"><i
                            class="Hui-iconfont">&#xe6e2;</i></a></td>
            </tr>
        </foreach>
        </tbody>
    </table>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">


    function deleteBatch() {
        var ids = [];
        $.each($("input[type='checkbox']"), function (key, value) {
            if ($(value).is(":checked")) {
                var v_id = $(value).val();
                if (v_id) {
                    ids.push($(value).val());
                }
            }
        });
        console.log(ids);
        var json = {};
        json['ids'] = ids;
        $.ajax({
            url:"{:U('/Index/Duty/section_batch_del')}",
            type: 'POST',
            dataType: "JSON",
            contentType: 'application/json',
            data: JSON.stringify(json),
            success: function (data) {
                if(data.status == 0){
                    $.each(data['data'], function(key,value){
                       $("#" + value).remove();
                    });
                    $("#checkMg").prop("checked",false);
                }
                layer.msg('已删除!', {icon: 1, time: 1000});

            },
            error: function (data) {
                console.log(data.msg);
            },
        });
    }


    /*管理员-角色-添加*/
    function admin_role_add(title, url, w, h) {
        layer_show(title, url, w, h);
    }
    /*管理员-角色-编辑*/
    function admin_role_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    /*管理员-角色-删除*/
    function admin_role_del(obj, url) {
        layer.confirm('工务段删除须谨慎，确认要删除吗？', function () {
            $.ajax({
                type: 'GET',
                dataType: "JSON",
                url: url,
                contentType: 'application/json',
                success: function () {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    }
</script>
</body>
</html>